package com.totoro.tymapping.enums;

import com.totoro.tymapping.constants.SlotTypeConst;
import com.totoro.tymapping.executor.slotparse.SlotParseExecutor;
import com.totoro.tymapping.executor.slotparse.impl.DragonCoreExecutor;
import com.totoro.tymapping.executor.slotparse.impl.MinecraftExecutor;
import com.totoro.tymapping.executor.slotparse.impl.OriginExecutor;

/**
 * @author Totoro
 * @version 0.1.0
 * @date 2025/8/13 - 16:07
 * @description 槽位解析执行器枚举
 **/
public enum SlotParseExecutorEnum {
    ORIGIN(SlotTypeConst.SLOT_TYPE_ORIGIN, new OriginExecutor()),
    MINECRAFT(SlotTypeConst.SLOT_TYPE_MINECRAFT, new MinecraftExecutor()),
    DRAGON_CORE(SlotTypeConst.SLOT_TYPE_DRAGON_CORE, new DragonCoreExecutor());

    private String slotType;
    private SlotParseExecutor slotParseExecutor;

    SlotParseExecutorEnum(String slotType, SlotParseExecutor slotParseExecutor) {
        this.slotType = slotType;
        this.slotParseExecutor = slotParseExecutor;
    }

    public static SlotParseExecutor getSlotParseExecutor(String slot) {
        for (SlotParseExecutorEnum value : values()) {
            if (slot.startsWith(value.slotType)) {
                return value.slotParseExecutor;
            }
        }
        return null;
    }

}
